<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>

</body>
<script src="../../../jquery-1.12.4.min.js"></script>
<script>
    var arr = Array.from({
        length: 1000000
    }, (v, i) => i);

    console.time('for')
    var i = 0;
    for (; i < arr.length; i++) {
        i += arr[i];
    }
    console.timeEnd('for')


    console.time('each')
    var j = 0;
    $.each(arr, function(index, item) {
        j += item;
    })
    console.timeEnd('each')
</script>

</html>